package com.api.common.utils.VER.EnumVer;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

@Documented
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(Enum.List.class)
@Constraint(validatedBy = {EnumValidator.class})
public @interface Enum {

    String message() default "{*.validation.constraint.Enum.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    /**
     * 要校验的枚举类
     *
     * @return 枚举类
     */
    Class<?> clazz();

    /**
     * 要校验枚举类的哪个字段，这个字段通过getxxx()方法获取,返回方法的名称
     *
     * @return 方法的名称
     */
    String method() default "ordinal";

    /**
     * 是否允许null值，默认是允许
     */
    boolean allowNull() default false;


    @Documented
    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
    @Retention(RetentionPolicy.RUNTIME)
    @interface List {
        Enum[] value();
    }
}

